package com.itheima.entity;

import java.io.Serializable;

public class Result implements Serializable {
    private boolean flag;//执行结果，true为执行成功 false为执行失败

    private Integer code;//后端返回的的错误代码或正确代码

    private String message;//返回提示信息，主要用于页面提示信息

    private Object data;//返回数据

    public static Result success (String message) {
        return new Result(true,200,message);
    }

    public static Result success(String message, Object data) {
        return new Result(true, 200, message, data);
    }

    public static Result fail(int code, String message) {
        return new Result(false,code,message,null);
    }

    public static Result fail(String message) {
        return new Result(false,500,message,null);
    }

    public Result() {
    }

    public Result(boolean flag, Integer code, String message) {
        this.flag = flag;
        this.code = code;
        this.message = message;
    }

    public Result(Integer code, Object data) {
        this.code = code;
        this.data = data;
    }

    public Result(boolean flag, Integer code, String message, Object data) {
        this.flag = flag;
        this.code = code;
        this.message = message;
        this.data = data;
    }



    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public boolean isFlag() {
        return flag;
    }

    public void setFlag(boolean flag) {
        this.flag = flag;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
